#include "internal.h"

static void set_next_buddy(struct sched_entity *se)
{
    for_each_sched_entity(se)
    {
        if (WARN_ON_ONCE(!se->on_rq))
            return;
        if (se_is_idle(se))
            return;
        cfs_rq_of(se)->next = se;
    }
}

static void __clear_buddies_next(struct sched_entity *se)
{
    for_each_sched_entity(se)
    {
        struct cfs_rq *cfs_rq = cfs_rq_of(se);
        if (cfs_rq->next != se)
            break;

        cfs_rq->next = NULL;
    }
}

static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
    if (cfs_rq->next == se)
        __clear_buddies_next(se);
}
